<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 12088
  Date: 2023/7/28
  Time: 9:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的信息</title>
    <script src="js/jquery.js"></script>
    <link rel="stylesheet" href="js/layui/css/layui.css">
    <script>
    </script>
</head>



<style>
    body::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: url("img/bg4.jpeg");
        /* 设置背景图片透明度 */
        opacity: 0.1;
        z-index: -1; /* 将伪元素放置于页面下方 */
    }

</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header  layui-bg-blue">
        <div class="layui-logo  layui-bg-blue layui-nav-img"
             style="font-weight: bold;font-size: 17px">
            <img src="img/bg3.jpg" alt="logo" style="width: 55px; height: auto;">
            石油大学软件缺陷管理系统</div>
        <ul class="layui-nav layui-layout-left"></ul>
        <c:if test="${loginUser==null}">
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item"><a href="login.jsp">请登录</a></li>
            </ul>
        </c:if>
        <c:if test="${loginUser!=null}">
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item"><a>${loginUser.username}</a></li>
                <li class="layui-nav-item"><a href="authLogout">退出登录</a></li>
            </ul>
        </c:if>
    </div>

    <div class="layui-side layui-bg-blue">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <!-- 侧边栏 -->
                <jsp:include page="menu.jsp">
                    <jsp:param value="active" name="My_active"/>
                </jsp:include>
            </ul>
        </div>
    </div>

    <div class="layui-body">



        <form class="layui-form layui-form-pane" action="login.jsp">
            <input type="hidden" name="id" class="layui-input" value="${loginUser.id}">
<%--            <input type="hidden" id="username" class="layui-input" value="${loginUser.username}">--%>
<%--            <input type="hidden" id="realName" class="layui-input" value="${loginUser.realName}">--%>
<%--            <input type="hidden" id="userSex" class="layui-input" value="${loginUser.userSex}">--%>
<%--            <input type="hidden" id="userPhone" class="layui-input" value="${loginUser.userPhone}">--%>
<%--            <input type="hidden" id="userText" class="layui-input" value="${loginUser.userText}">--%>



            <div class="layui-inline">
            <div class="layui-form-item"style="padding: 9px 15px;">
                <label class="layui-form-label">用户名：</label>
                <div class="layui-input-block" >
                    <input type="text"  name="username" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input" value="${loginUser.username}">
                </div>
            </div>
            </div>


            <div class="layui-inline">
            <div class="layui-form-item"style="padding: 9px 15px;">
                <label class="layui-form-label">姓名：</label>
                <div class="layui-input-block" >
                    <input type="text" name="realName" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input" value="${loginUser.realName}">
                </div>
            </div>
            </div>


            <div>
            <div class="layui-inline" >
            <div class="layui-form-item"style="padding: 9px 15px;">
                <label class="layui-form-label">性别：</label>
                <div class="layui-input-block">
                    <input name="userSex" type="radio" value="男" ${loginUser.userSex=='男'?'checked':''} class="layui-input" title="男" />
                    <input name="userSex" type="radio" value="女" ${loginUser.userSex=='女'?'checked':''} class="layui-input" title="女"/>
                </div>
            </div>
            </div>

            <div class="layui-inline">
            <div class="layui-form-item"style="padding: 9px 15px;margin-left: 35px">
                <label class="layui-form-label">类型：</label>
                <div class="layui-input-block">
                    <input name="userType" type="radio" value="管理员" ${loginUser.userType=='管理员'?'checked':''} class="layui-input" title="管理员" disabled/>
                    <input name="userType" type="radio" value="普通用户" ${loginUser.userType=='普通用户'?'checked':''} class="layui-input" title="普通用户" disabled/>
                </div>
            </div>
            </div>
            </div>

            <div class="layui-form-item"style="padding: 9px 15px;">
                <label class="layui-form-label">手机：</label>
                <div class="layui-input-block" >
                    <input type="text" name="userPhone" autocomplete="off"  style="width:210px;"  placeholder="请输入" lay-verify="required" class="layui-input" value="${loginUser.userPhone}">
                </div>
            </div>

            <div>
            <div class="layui-inline" >
            <div class="layui-form-item layui-form-text"style="padding: 9px 15px;">
                <label class="layui-form-label" style="width: 500px">备注：</label>
                <div class="layui-input-block">
                    <textarea type="text" name="userText" class="layui-textarea" style="height: 150px;padding-left: 10px;width: 500px" placeholder="请输入内容......">${loginUser.userText}</textarea>
                </div>
            </div>
            </div>

            <div class="layui-inline" >
            <div class="layui-form-item" style="padding: 9px 15px;">
                <div class="layui-input-wrap">
                    <label class="layui-form-label">密码：</label>
                    <input type="password" name="password" style="width: 250px" value="${loginUser.password}" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input" id="reg-password" lay-affix="eye">
                </div>
            </div>
            <div class="layui-form-item" style="padding: 9px 15px;">
                <div class="layui-input-wrap">
                    <label class="layui-form-label">确认密码：</label>
                    <input type="password" name="confirmPassword" style="width: 250px" value="${loginUser.password}" lay-verify="required|confirmPassword" placeholder="确认密码" autocomplete="off" class="layui-input" lay-affix="eye">
                </div>
            </div>
            </div>
            </div>






            <div class="layui-form-item"style="padding: 9px 15px;">
                <button class="layui-btn layui-bg-blue" lay-submit lay-filter="submit-button">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </form>

    </div>


</div>

<script src="js/layui/layui.js" charset="utf-8"></script>
<script>

    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form, layer = layui.layer, layedit = layui.layedit;
        var util = layui.util;
        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');





        form.verify({
            content: function (value) {
                layedit.sync(editIndex);
            },


            confirmPassword: function(value, item){
                var passwordValue = $('#reg-password').val();
                if(value !== passwordValue){
                    return '两次密码输入不一致';
                }
            }
        });

    //监听提交
        form.on('submit(submit-button)', function (data) {
            $.post("userEdit", data.field, function () {
                data=data.field;
                console.log(data);

                // location.reload();
            }, "text");//
            alert("个人信息修改成功，请重新登入")
            // window.location.href = "login.jsp";
            return;
        })






    });
</script>



</body>
</html>
